Fixes and workaround for platforms where Qt uses OpenGL ES
authorAdrian Bunk <bunk@debian.org>
Sun, 15 Nov 2020 14:03:16 +0000 (16:03 +0200)
committerAdrian Bunk <bunk@debian.org>
Sat, 12 Dec 2020 23:20:45 +0000 (01:20 +0200)
debian/patches/81_allow_gles_platforms.patch [new file with mode: 0644]
debian/patches/82_allow_gles_platforms.patch [new file with mode: 0644]
debian/patches/83_allow_gles_platforms.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/81_allow_gles_platforms.patch b/debian/patches/81_allow_gles_platforms.patch
new file mode 100644 (file)
index 0000000..938d842
--- /dev/null
@@ -0,0 +1,46 @@
+From d7fe3fe9df8c26b5a9ea036511cdb1640f5ae2b4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
+Date: Sun, 28 Jun 2020 22:13:32 +0200
+Subject: Replace last glDrawBuffer call with glDrawBuffers(1, ...)
+
+glDrawBuffer is only available in Desktop OpenGL, while the equivalent
+glDrawBuffers is valid also for GLES.
+
+Just defining glDrawBuffer as an empty macro is obviously not the right
+solution, as the call is also required on GLES. This also causes
+a compilation failure - GL.h may be included via GLX.h on X11 platforms,
+and the glDrawBuffer prototype declaration becomes malformed.
+---
+ Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h | 3 ++-
+ ThirdParty/glew/vtk_glew.h.in                              | 1 -
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h
+index 5632547459..ae3bd53f05 100644
+--- a/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h
++++ b/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2DPrivate.h
+@@ -324,7 +324,8 @@ public:
+       if (this->SavedDrawBuffer != GL_BACK_LEFT)
+       {
+-        glDrawBuffer(this->SavedDrawBuffer);
++        const GLenum bufs[1] = { static_cast<GLenum>(this->SavedDrawBuffer) };
++        ::glDrawBuffers(1, bufs);
+       }
+       ostate->vtkglClearColor(this->SavedClearColor[0], this->SavedClearColor[1],
+diff --git a/ThirdParty/glew/vtk_glew.h.in b/ThirdParty/glew/vtk_glew.h.in
+index 6aa8c2ee9e..6afed1d655 100644
+--- a/ThirdParty/glew/vtk_glew.h.in
++++ b/ThirdParty/glew/vtk_glew.h.in
+@@ -52,7 +52,6 @@
+ /* some fixes for both ES 2 and 3 */
+ #ifdef GL_ES_VERSION_3_0
+-#  define glDrawBuffer(arg)
+ #  define GL_BACK_LEFT 0
+ #  define GL_BACK_RIGHT 0
+ #  define GL_FRONT_LEFT 0
+-- 
+2.20.1
+
diff --git a/debian/patches/82_allow_gles_platforms.patch b/debian/patches/82_allow_gles_platforms.patch
new file mode 100644 (file)
index 0000000..ee1d4e3
--- /dev/null
@@ -0,0 +1,61 @@
+From b48706fdff04672bdad6d10afae23afc26b89178 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
+Date: Tue, 9 Jun 2020 17:11:12 +0200
+Subject: Fix compilation when Qt is built for GLES platforms
+
+On GLES 2.0/3.0 platforms (more specifically, for Qt5 "opengl es2" builds),
+QOpenGLFunctions_3_2_Core does not exist.
+
+After the last restructuring, from the GL 3.2 Core functions only
+glDrawBuffer is used. glDrawBuffer can be trivially replaced with
+glDrawBuffers, which is part of OpenGL 2.0 and GLES 3.0, and as an
+extension in many GLES 2.0 implementations.
+---
+ GUISupport/Qt/QVTKRenderWindowAdapter.cxx | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
+index 5a66e236df..530cec9b2a 100644
+--- a/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
++++ b/GUISupport/Qt/QVTKRenderWindowAdapter.cxx
+@@ -28,9 +28,8 @@
+ #include <QOffscreenSurface>
+ #include <QOpenGLContext>
+ #include <QOpenGLDebugLogger>
++#include <QOpenGLExtraFunctions>
+ #include <QOpenGLFramebufferObject>
+-#include <QOpenGLFunctions>
+-#include <QOpenGLFunctions_3_2_Core>
+ #include <QPointer>
+ #include <QScopedValueRollback>
+ #include <QScreen>
+@@ -334,14 +333,15 @@ public:
+     {
+       return false;
+     }
+-    QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions<QOpenGLFunctions_3_2_Core>();
++    QOpenGLExtraFunctions* f = this->Context->extraFunctions();
+     if (!f)
+     {
+       return false;
+     }
+     f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetId);
+-    f->glDrawBuffer(targetAttachment);
++    const GLenum bufs[1] = { static_cast<GLenum>(targetAttachment) };
++    f->glDrawBuffers(1, bufs);
+     f->glBindFramebuffer(GL_READ_FRAMEBUFFER, this->FBO->handle());
+     f->glReadBuffer(
+@@ -436,7 +436,7 @@ public:
+   {
+     Q_ASSERT(this->Context && this->FBO);
+-    QOpenGLFunctions_3_2_Core* f = this->Context->versionFunctions<QOpenGLFunctions_3_2_Core>();
++    QOpenGLFunctions* f = this->Context->functions();
+     if (f)
+     {
+       // now clear alpha otherwise we end up blending the rendering with
+-- 
+2.20.1
+
diff --git a/debian/patches/83_allow_gles_platforms.patch b/debian/patches/83_allow_gles_platforms.patch
new file mode 100644 (file)
index 0000000..2e862f5
--- /dev/null
@@ -0,0 +1,29 @@
+From 572a554967c84bba101cf03e3d22c89113407d49 Mon Sep 17 00:00:00 2001
+From: Adrian Bunk <bunk@debian.org>
+Date: Fri, 11 Dec 2020 10:42:37 +0200
+Subject: HACK: QVTKOpenGLWindow.cxx: Define GL_BACK_{LEFT,RIGHT} for Qt with
+ OpenGL ES
+
+---
+ GUISupport/Qt/QVTKOpenGLWindow.cxx | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/GUISupport/Qt/QVTKOpenGLWindow.cxx b/GUISupport/Qt/QVTKOpenGLWindow.cxx
+index 3bddc19809..79d5c2b653 100644
+--- a/GUISupport/Qt/QVTKOpenGLWindow.cxx
++++ b/GUISupport/Qt/QVTKOpenGLWindow.cxx
+@@ -35,6 +35,11 @@
+ #include "vtkObjectFactory.h"
+ #include "vtkOpenGLState.h"
++#ifndef GL_BACK_LEFT
++#define GL_BACK_LEFT GL_BACK
++#define GL_BACK_RIGHT GL_BACK
++#endif
++
+ QVTKOpenGLWindow::QVTKOpenGLWindow(QOpenGLWindow::UpdateBehavior ub, QWindow* p)
+   : QVTKOpenGLWindow(vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New(), nullptr, ub, p)
+ {
+-- 
+2.20.1
+
index d204b798fa311a8cae999d403ff918869b44ca4e..ef2e24cf7a8f1ff19d1ebbc67fa48dc5df42481c 100644 (file)
@@ -6,4 +6,7 @@
 60_fix_path_perl.patch
 70_fix_python_numpy_warning.patch
 80_allow_gles_platforms.patch
+81_allow_gles_platforms.patch
+82_allow_gles_platforms.patch
+83_allow_gles_platforms.patch
 90_fix_freetype_compilation.patch